package com.ideal.manage.esms.repository.monitor;


import com.ideal.manage.esms.bean.esms.EsmsUnitCellScanBase;
import com.ideal.manage.esms.repository.framework.BaseRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

public interface UnitCellDataScanBaseRepository extends BaseRepository<EsmsUnitCellScanBase, String> {

    @Query("select u from EsmsUnitCellScanBase u where u.cellName=?1 and u.dateTime>?2 and u.dateTime<?3 order by u.dateTime desc ")
    List<EsmsUnitCellScanBase> findCodeByData(String code, Date startTime, Date endTime);

    @Query("select u from EsmsUnitCellScanBase u where u.macid=?1 and u.cellName in ?2 and u.projectIp =?3" +
            " and u.dateTime > ?4 and u.dateTime < ?5 order by u.dateTime asc ")
    List<EsmsUnitCellScanBase> findByGroupBattery(String macid, List<String> code, String ip, Date start, Date end);

    @Query("select u from EsmsUnitCellScanBase u where u.macid=?1 and u.cellName=?2 and u.projectIp=?3 " +
            "and u.dateTime > ?4 and u.dateTime < ?5 order by u.dateTime asc ")
    List<EsmsUnitCellScanBase> findByOneBatutery(String macid, String s, String ip, Date start, Date end);
    
    @Query("select u from EsmsUnitCellScanBase u where u.macid=?1 and u.projectIp=?2 and u.dateTime > ?3 " +
            "and u.dateTime < ?4 order by u.dateTime asc ")
    List<EsmsUnitCellScanBase> findByOneBatterys(String macid, String ip, Date start, Date end);
    @Query("select u from EsmsUnitCellScanBase u where u.macid=?1 and u.dateTime>?2 and u.dateTime<?3 " +
            "order by u.dateTime asc ")
    List<EsmsUnitCellScanBase> findByBattery(String macid, Date startTime, Date endTime);
}
